/**
 *
 */
package com.im.app.model;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;


/**
 * 版本: [1.0]
 * 功能说明:
 * @author : WChao 创建时间: 2017年7月26日 下午3:13:47
 */
@Data
@TableName("user")
public class User implements Serializable{

	private static final long serialVersionUID = 1L;
	/**
	 * 用户id;
	 */
	@TableId(type = IdType.ASSIGN_UUID)
	private String userId;
	private Integer adminId;
	/**
	 * user nick
	 */
	@Excel(name="昵称",orderNum = "0",width = 20)
	private String name;
	/**
	 * 用户头像
	 */
	private String avatar;
	/**
	 * 是否在线
	 */
	@TableField("online")
	private boolean online;

	/**
	 * 用户状态
	 */
	private Integer status;

	/**
	 * 用户所属终端;(1 web、2 android、3 ios等)
	 */
	private Integer terminal;
	/**
	 * 用户打开的浏览器;(1 微信、2 其他浏览器)
	 */
	private int webType;

	private String createIp;

	private String createCity;

	private Integer verify;

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date createLoginTime;
	/**
	 * 用户登陆ip
	 */
	@TableField("last_login_ip")
	@Excel(name="ip",orderNum = "1",width = 20)
	private String ip;
	/**
	 * 用户登陆地址
	 */
	@TableField("last_login_city")
	@Excel(name="地址",orderNum = "2",width = 20)
	private String ipAddress;

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date lastLoginTime;

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date loginOutTime;

	private int loginCount;

	/**
	 * 绑定客服
	 */
	private String kefuId;


	/**
	 * 客服有到期时间，用户没有
	 */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date endTime;
	/**
	 * 创建时间
	 */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Excel(name = "时间",orderNum = "3", width = 20, format = "yyyy-MM-dd HH:mm:ss")
	private Date createTime;

	private String deviceId;

	private Integer iswechat;
	/**
	 * 卡密
	 */
	private String kamicode;
	/**
	 * 创建人
	 */
	private String createUser;
	/**
	 * 激活状态
	 */
	private Integer actStatus;
	/**
	 * 设备型号
	 */
	private String mobileType;

	private Integer translate;

	@TableField(exist = false)
	private String token;

	@TableField(exist = false)
	private String conversationCount;

	private Integer avatarShow;
	/**
	 * 1 普通用户  3 客服
	 */
	@TableField("app_manger_level")
	private Integer appMangerLevel;

	/**
	 * 询前表单
	 * 0-关闭  1-开启
	 */
	private Integer isPreForm;

	/**
	 * 是否新用户提醒
	 * 0-关闭  1-开启
	 */
	private Integer isNotice;

	private Integer nameType;

	private String joinUrl;


	private boolean proxy;


	private String remark;

	private Integer urlChange;

	private Integer ipCheck;

	private Integer securityUrl;






	//	private List<User> friends;
//	/**
//	 * 群组列表;
//	 */
//	private List<Group> groups;






	public User clone(){
		User cloneUser = new User();
		BeanUtil.copyProperties(this, cloneUser,"friends","groups");
		return cloneUser;
	}

	public org.jim.core.packets.User toJIMUser(){
		org.jim.core.packets.User userInfo = org.jim.core.packets.User.newBuilder().build();
		userInfo.setUserId(getUserId());
		userInfo.setAvatar(getAvatar());
		userInfo.setNick(getName());
		userInfo.setTerminal("1");
		userInfo.setToken(getToken());
		return userInfo;
	}

	public User() {
	}

	public User(String userId, String name, String avatar, String createIp, String createCity, Date createLoginTime, String ip, String ipAddress, Date lastLoginTime, String kefuId, Date createTime, String deviceId, String mobileType, String token, Integer appMangerLevel) {
		this.userId = userId;
		this.name = name;
		this.avatar = avatar;
		this.createIp = createIp;
		this.createCity = createCity;
		this.createLoginTime = createLoginTime;
		this.ip = ip;
		this.ipAddress = ipAddress;
		this.lastLoginTime = lastLoginTime;
		this.kefuId = kefuId;
		this.createTime = createTime;
		this.deviceId = deviceId;
		this.mobileType = mobileType;
		this.token = token;
		this.appMangerLevel = appMangerLevel;
	}
}
